<template>
  <div class="sex">
    <div class="top">
      <div class="title">
        <div>男女比例</div>
        <img src="@/views/screen/images/dataScreen-title.png" alt="">
      </div>
    </div>
    <div class="issex">
      <div class="man">
        <span style="flex: 10%; color: aliceblue;">男士</span>
        <img src="@/views/screen/images/man.png" alt="" srcset="">
      </div>
      <div class="girl">
        <span style="flex: 10%;color: aliceblue;">女生</span>
        <img src="@/views/screen/images/woman.png" alt="" srcset="">
      </div>
    </div>
    <div class="chart" ref="echart">
    </div>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue';
import * as echarts from 'echarts';

const echart = ref()
onMounted(() => {
  const myChart = echarts.init(echart.value)
  let option = {
    title: {
      text: '男女比例',
      textStyle: {
        color: 'skyblue',
      },
      left: 'center'
    },
    xAxis: {
      show: false,
      min: 0,
      max: 100
    },
    yAxis: { type: 'category', show: false },
    series: [
      {
        type: 'bar',
        data: [58],
        barWidth: 20,
        z: 100,
        itemStyle: {
          color: 'skyblue',
          borderRadius: 20
        }
      },
      {
        type: 'bar',
        data: [100],
        barWidth: 20,
        barGap: '-100%',
        itemStyle: {
          color: 'pink',
          borderRadius: 20
        }
      }
    ],
    grid: {
      left: 0,
      right: 0,
      top: 0,
      bottom: 0
    }
  }
  myChart.setOption(option);
})
</script>

<style lang="scss" scoped>
.sex {
  width: 100%;
  height: 300;
  background: url(@/views/screen/images/dataScreen-main-cb.png) no-repeat;
  background-size: 100% 100%;
  margin-bottom: 10px;

  .top {
    .title {
      height: 65px;
      color: white;
      font-size: 22px;
      padding-left: 10px;
    }
  }

  .issex {
    width: 100%;
    margin-top: 20px;
    display: flex;
    justify-content: space-evenly;
    .man {
      width: 100px;
      height: 100px;
      background: url(@/views/screen/images/man-bg.png) no-repeat;
      background-size: 100% 100%;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
    }
    .girl {
      width: 100px;
      height: 100px;
      background: url(@/views/screen/images/woman-bg.png) no-repeat;
      background-size: 100% 100%;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
    }
  }
  .chart {
    width: 100%;
    height: 125px;
  }
}
</style>
